SPB Git

spb/chat-spboucher Public

Private universal chat interface over the OpenRouter ecosystem — 400+ models, branching, streaming, usage tracking. Next.js 16 + SQLite, PWA, deployed on m4m64a at chat.spboucher.ai

TypeScript 78.8% CSS 15.1% JavaScript 4.9% Shell 1.2%
903 B · 26 lines typescript
Raw Blame History
1// Author: Simon-Pierre Boucher2// Contact: contact@spboucher.ai3// Project: chat.spboucher.ai45// "Stop" aborts the upstream OpenRouter stream — never fake cancellation.67import { NextResponse, type NextRequest } from "next/server";8import { requireSession } from "@/lib/auth/guard";9import { cancelGeneration, generationState } from "@/lib/generate";1011export const runtime = "nodejs";1213type Params = { params: Promise<{ id: string }> };1415export async function POST(_req: NextRequest, { params }: Params) {16  const { unauthorized } = await requireSession();17  if (unauthorized) return unauthorized;18  const { id } = await params;19  const cancelled = cancelGeneration(id);20  const gen = generationState(id);21  if (!cancelled && !gen) {22    return NextResponse.json({ error: "Generation not found." }, { status: 404 });23  }24  return NextResponse.json({ ok: true, state: gen?.state ?? "cancelled" });25}26